//:  -L+libcurl+Ws2_32+Advapi32+zlib -version=CurlTest
module libcurl ;

public {
	enum  {
	  CURLINFO_TEXT = 0,
	  CURLINFO_HEADER_IN,    
	  CURLINFO_HEADER_OUT,   
	  CURLINFO_DATA_IN,      
	  CURLINFO_DATA_OUT,     
	  CURLINFO_END
	}; 

	enum  {
	  CURLE_OK = 0,
	  CURLE_UNSUPPORTED_PROTOCOL,    
	  CURLE_FAILED_INIT,             
	  CURLE_URL_MALFORMAT,           
	  CURLE_URL_MALFORMAT_USER,      
	  CURLE_COULDNT_RESOLVE_PROXY,   
	  CURLE_COULDNT_RESOLVE_HOST,    
	  CURLE_COULDNT_CONNECT,         
	  CURLE_FTP_WEIRD_SERVER_REPLY,  
	  CURLE_FTP_ACCESS_DENIED,       
	  CURLE_FTP_USER_PASSWORD_INCORRECT, 
	  CURLE_FTP_WEIRD_PASS_REPLY,    
	  CURLE_FTP_WEIRD_USER_REPLY,    
	  CURLE_FTP_WEIRD_PASV_REPLY,    
	  CURLE_FTP_WEIRD_227_FORMAT,    
	  CURLE_FTP_CANT_GET_HOST,       
	  CURLE_FTP_CANT_RECONNECT,      
	  CURLE_FTP_COULDNT_SET_BINARY,  
	  CURLE_PARTIAL_FILE,            
	  CURLE_FTP_COULDNT_RETR_FILE,   
	  CURLE_FTP_WRITE_ERROR,         
	  CURLE_FTP_QUOTE_ERROR,         
	  CURLE_HTTP_RETURNED_ERROR,     
	  CURLE_WRITE_ERROR,             
	  CURLE_MALFORMAT_USER,          
	  CURLE_FTP_COULDNT_STOR_FILE,   
	  CURLE_READ_ERROR,              
	  CURLE_OUT_OF_MEMORY,           
	  CURLE_OPERATION_TIMEOUTED,     
	  CURLE_FTP_COULDNT_SET_ASCII,   
	  CURLE_FTP_PORT_FAILED,         
	  CURLE_FTP_COULDNT_USE_REST,    
	  CURLE_FTP_COULDNT_GET_SIZE,    
	  CURLE_HTTP_RANGE_ERROR,        
	  CURLE_HTTP_POST_ERROR,         
	  CURLE_SSL_CONNECT_ERROR,       
	  CURLE_BAD_DOWNLOAD_RESUME,     
	  CURLE_FILE_COULDNT_READ_FILE,  
	  CURLE_LDAP_CANNOT_BIND,        
	  CURLE_LDAP_SEARCH_FAILED,      
	  CURLE_LIBRARY_NOT_FOUND,       
	  CURLE_FUNCTION_NOT_FOUND,      
	  CURLE_ABORTED_BY_CALLBACK,     
	  CURLE_BAD_FUNCTION_ARGUMENT,   
	  CURLE_BAD_CALLING_ORDER,       
	  CURLE_HTTP_PORT_FAILED,        
	  CURLE_BAD_PASSWORD_ENTERED,    
	  CURLE_TOO_MANY_REDIRECTS ,     
	  CURLE_UNKNOWN_TELNET_OPTION,   
	  CURLE_TELNET_OPTION_SYNTAX ,   
	  CURLE_OBSOLETE,	         
	  CURLE_SSL_PEER_CERTIFICATE,    
	  CURLE_GOT_NOTHING,             
	  CURLE_SSL_ENGINE_NOTFOUND,     
	  CURLE_SSL_ENGINE_SETFAILED,    /* 54 - can not set SSL crypto engine as
					    default */
	  CURLE_SEND_ERROR,              
	  CURLE_RECV_ERROR,              
	  CURLE_SHARE_IN_USE,            
	  CURLE_SSL_CERTPROBLEM,         
	  CURLE_SSL_CIPHER,              
	  CURLE_SSL_CACERT,              
	  CURLE_BAD_CONTENT_ENCODING,    
	  CURLE_LDAP_INVALID_URL,        
	  CURLE_FILESIZE_EXCEEDED,       
	  CURLE_FTP_SSL_FAILED,           

	  CURL_LAST 
	} ;
	
	alias int curl_proxytype;
	
	static const int CURLAUTH_NONE= 0;
	static const int CURLAUTH_BASIC= (1<<0);
	static const int CURLAUTH_DIGEST= (1<<1);
	static const int CURLAUTH_GSSNEGOTIATE= (1<<2);
	static const int CURLAUTH_NTLM= (1<<3);
	static const int CURLAUTH_ANY = ~0;               
	static const int CURLAUTH_ANYSAFE= (~CURLAUTH_BASIC);
	alias CURLE_PARTIAL_FILE CURLE_FTP_PARTIAL_FILE ;
	alias CURLE_BAD_DOWNLOAD_RESUME CURLE_FTP_BAD_DOWNLOAD_RESUME ;

	static const int CURL_ERROR_SIZE= 256;

	enum  {
	  CURLFTPSSL_NONE,    
	  CURLFTPSSL_TRY,     
	  CURLFTPSSL_CONTROL, 
	  CURLFTPSSL_ALL,     
	  CURLFTPSSL_LAST     
	};
	alias int curl_ftpssl;

	static const int CURLOPTTYPE_LONG= 0;
	static const int CURLOPTTYPE_OBJECTPOINT= 10000;
	static const int CURLOPTTYPE_FUNCTIONPOINT= 20000;
	static const int CURLOPTTYPE_OFF_T= 30000;

	const int LONG = CURLOPTTYPE_LONG;
	const int OBJECTPOINT = CURLOPTTYPE_OBJECTPOINT;
	const int FUNCTIONPOINT = CURLOPTTYPE_FUNCTIONPOINT;
	const int OFF_T = CURLOPTTYPE_OFF_T;

	const int CURLOPT_NOTHING=0;
	const int CURLOPT_FILE=10001;
	const int CURLOPT_URL=10002;
	const int CURLOPT_PORT=3;
	const int CURLOPT_PROXY=10004;
	const int CURLOPT_USERPWD=10005;
	const int CURLOPT_PROXYUSERPWD=10006;
	const int CURLOPT_RANGE=10007;
	const int CURLOPT_INFILE=10009;
	
	  /* buffer to receive error messages in; must be at least CURL_ERROR_SIZE
	   * bytes big. If this is not used; error messages go to stderr instead: */
	const int CURLOPT_ERRORBUFFER=10010;

	  /* Function that will be called to store the output (instead of fwrite). The
	   * parameters will use fwrite() syntax; make sure to follow them. */
	const int CURLOPT_WRITEFUNCTION=20011;

	  /* Function that will be called to read the input (instead of fread). The
	   * parameters will use fread() syntax; make sure to follow them. */
	const int CURLOPT_READFUNCTION=20012;

	  
	const int CURLOPT_TIMEOUT=13;

	  /* If the CURLOPT_INFILE is used; this can be used to inform libcurl about
	   * how large the file being sent really is. That allows better error
	   * checking and better verifies that the upload was succcessful. -1 means
	   * unknown size.
	   *
	   * For large file support; there is also a _LARGE version of the key
	   * which takes an off_t type; allowing platforms with larger off_t
	   * sizes to handle larger files.  See below for INFILESIZE_LARGE.
	   */
	const int CURLOPT_INFILESIZE=14;

	  
	const int CURLOPT_POSTFIELDS=10015;

	  
	const int CURLOPT_REFERER=10016;

	  /* Set the FTP PORT string (interface name; named or numerical IP address)
	     Use i.e '-' to use default address. */
	const int CURLOPT_FTPPORT=10017;

	  
	const int CURLOPT_USERAGENT=10018;

	  /* If the download receives less than "low speed limit" bytes/second
	   * during "low speed time" seconds; the operations is aborted.
	   * You could i.e if you have a pretty high speed connection; abort if
	   * it is less than 2000 bytes/sec during 20 seconds.   
	   */

	  
	const int CURLOPT_LOW_SPEED_LIMIT=19;

	  
	const int CURLOPT_LOW_SPEED_TIME=20;

	  /* Set the continuation offset.
	   *
	   * Note there is also a _LARGE version of this key which uses
	   * off_t types; allowing for large file offsets on platforms which
	   * use larger-than-32-bit off_t's.  Look below for RESUME_FROM_LARGE.
	   */
	const int CURLOPT_RESUME_FROM=21;

	  
	const int CURLOPT_COOKIE=10022;

	  
	const int CURLOPT_HTTPHEADER=10023;

	  
	const int CURLOPT_HTTPPOST=10024;

	  
	const int CURLOPT_SSLCERT=10025;

	  
	const int CURLOPT_SSLCERTPASSWD=10026;
	  
	const int CURLOPT_SSLKEYPASSWD=10026;
	  
	  
	const int CURLOPT_CRLF=27;

	  
	const int CURLOPT_QUOTE=10028;

	  /* send FILE * or void * to store headers to; if you use a callback it
	     is simply passed to the callback unmodified */
	const int CURLOPT_WRITEHEADER=10029;

	  /* point to a file to read the initial cookies from; also enables
	     "cookie awareness" */
	const int CURLOPT_COOKIEFILE=10031;

	  /* What version to specifly try to use.
	     See CURL_SSLVERSION defines below. */
	const int CURLOPT_SSLVERSION=32;

	  
	const int CURLOPT_TIMECONDITION=33;

	  /* Time to use with the above condition. Specified in number of seconds
	     since 1 Jan 1970 */
	const int CURLOPT_TIMEVALUE=34;

	  
	  
	const int CURLOPT_HTTPREQUEST=10035;

	  /* Custom request; for customizing the get command like
	     HTTP: DELETE; TRACE and others
	     FTP: to use a different list command
	     */
	const int CURLOPT_CUSTOMREQUEST=10036;

	  
	const int CURLOPT_STDERR=10037;

	  

	  
	const int CURLOPT_POSTQUOTE=10039;

	  /* Pass a pointer to string of the output using full variable-replacement
	     as described elsewhere. */
	const int CURLOPT_WRITEINFO=10040;

	const int CURLOPT_VERBOSE=41;
	const int CURLOPT_HEADER=42;
	const int CURLOPT_NOPROGRESS=43;
	const int CURLOPT_NOBODY=44;
	const int CURLOPT_FAILONERROR=45;
	const int CURLOPT_UPLOAD=46;
	const int CURLOPT_POST=47;
	const int CURLOPT_FTPLISTONLY=48;

	const int CURLOPT_FTPAPPEND=50;

	  /* Specify whether to read the user+password from the .netrc or the URL.
	   * This must be one of the CURL_NETRC_* enums below. */
	const int CURLOPT_NETRC=51;

	const int CURLOPT_FOLLOWLOCATION=52;

	  /* This FTPASCII name is now obsolete; to be removed; use the TRANSFERTEXT
	     instead. It goes for more protocols than just ftp... */
	const int CURLOPT_FTPASCII=53;

	const int CURLOPT_TRANSFERTEXT=53;
	const int CURLOPT_PUT=54;

	const int CURLOPT_MUTE=55;

	  /* Function that will be called instead of the internal progress display
	   * function. This function should be defined as the curl_progress_callback
	   * prototype defines. */
	const int CURLOPT_PROGRESSFUNCTION=20056;

	  
	const int CURLOPT_PROGRESSDATA=10057;

	  
	const int CURLOPT_AUTOREFERER=58;

	  /* Port of the proxy; can be set in the proxy string as well with:
	     "[host]:[port]" */
	const int CURLOPT_PROXYPORT=59;

	  
	const int CURLOPT_POSTFIELDSIZE=60;

	  
	const int CURLOPT_HTTPPROXYTUNNEL=61;

	  
	const int CURLOPT_INTERFACE=10062;

	  /* Set the krb4 security level; this also enables krb4 awareness.  This is a
	   * string; 'clear'; 'safe'; 'confidential' or 'private'.  If the string is
	   * set but doesn't match one of these; 'private' will be used.  */
	const int CURLOPT_KRB4LEVEL=10063;

	  
	const int CURLOPT_SSL_VERIFYPEER=64;
	  
	  /* The CApath or CAfile used to validate the peer certificate
	     this option is used only if SSL_VERIFYPEER is true */
	const int CURLOPT_CAINFO=10065;

	  
	const int CURLOPT_PASSWDFUNCTION=20066;

	  
	const int CURLOPT_PASSWDDATA=10067;
	  
	  
	const int CURLOPT_MAXREDIRS=68;

	  /* Pass a pointer to a time_t to get a possible date of the requested
	     document! Pass a NULL to shut it off. */
	const int CURLOPT_FILETIME=10069;

	  
	const int CURLOPT_TELNETOPTIONS=10070;

	  
	const int CURLOPT_MAXCONNECTS=71;

	  /* What policy to use when closing connections when the cache is filled
	     up */
	const int CURLOPT_CLOSEPOLICY=72;

	  
	const int CURLOPT_CLOSEFUNCTION=20073;

	  /* Set to explicitly use a new connection for the upcoming transfer.
	     Do not use this unless you're absolutely sure of this; as it makes the
	     operation slower and is less friendly for the network. */
	const int CURLOPT_FRESH_CONNECT=74;

	  /* Set to explicitly forbid the upcoming transfer's connection to be re-used
	     when done. Do not use this unless you're absolutely sure of this; as it
	     makes the operation slower and is less friendly for the network. */
	const int CURLOPT_FORBID_REUSE=75;

	  /* Set to a file name that contains random data for libcurl to use to
	     seed the random engine when doing SSL connects. */
	const int CURLOPT_RANDOM_FILE=10076;

	  
	const int CURLOPT_EGDSOCKET=10077;

	  /* Time-out connect operations after this amount of seconds; if connects
	     are OK within this time; then fine... This only aborts the connect
	     phase. [Only works on unix-style/SIGALRM operating systems] */
	const int CURLOPT_CONNECTTIMEOUT=78;

	  /* Function that will be called to store headers (instead of fwrite). The
	   * parameters will use fwrite() syntax; make sure to follow them. */
	const int CURLOPT_HEADERFUNCTION=20079;

	  /* Set this to force the HTTP request to get back to GET. Only really usable
	     if POST; PUT or a custom request have been used first.
	   */
	const int CURLOPT_HTTPGET=80;

	  /* Set if we should verify the Common name from the peer certificate in ssl
	   * handshake; set 1 to check existence; 2 to ensure that it matches the
	   * provided hostname. */
	const int CURLOPT_SSL_VERIFYHOST=81;

	  /* Specify which file name to write all known cookies in after completed
	     operation. Set file name to "-" (dash) to make it go to stdout. */
	const int CURLOPT_COOKIEJAR=10082;

	  
	const int CURLOPT_SSL_CIPHER_LIST=10083;

	  /* Specify which HTTP version to use! This must be set to one of the
	     CURL_HTTP_VERSION* enums set below. */
	const int CURLOPT_HTTP_VERSION=84;

	  /* Specificly switch on or off the FTP engine's use of the EPSV command. By
	     default; that one will always be attempted before the more traditional
	     PASV command. */     
	const int CURLOPT_FTP_USE_EPSV=85;

	  
	const int CURLOPT_SSLCERTTYPE=10086;

	  
	const int CURLOPT_SSLKEY=10087;

	  
	const int CURLOPT_SSLKEYTYPE=10088;

	  
	const int CURLOPT_SSLENGINE=10089;

	  /* set the crypto engine for the SSL-sub system as default
	     the param has no meaning...
	   */
	const int CURLOPT_SSLENGINE_DEFAULT=90;

	  
	const int CURLOPT_DNS_USE_GLOBAL_CACHE=91;

	  
	const int CURLOPT_DNS_CACHE_TIMEOUT=92;

	  
	const int CURLOPT_PREQUOTE=10093;

	  
	const int CURLOPT_DEBUGFUNCTION=20094;

	  
	const int CURLOPT_DEBUGDATA=10095;

	  
	const int CURLOPT_COOKIESESSION=96;

	  /* The CApath directory used to validate the peer certificate
	     this option is used only if SSL_VERIFYPEER is true */
	const int CURLOPT_CAPATH=10097;

	  
	const int CURLOPT_BUFFERSIZE=98;

	  /* Instruct libcurl to not use any signal/alarm handlers; even when using
	     timeouts. This option is useful for multi-threaded applications.
	     See libcurl-the-guide for more background information. */
	const int CURLOPT_NOSIGNAL=99;
	  
	  
	const int CURLOPT_SHARE=10100;

	  /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default);
	     CURLPROXY_SOCKS4 and CURLPROXY_SOCKS5. */
	const int CURLOPT_PROXYTYPE=101;

	  /* Set the Accept-Encoding string. Use this to tell a server you would like
	     the response to be compressed. */
	const int CURLOPT_ENCODING=10102;
	 
	  
	const int CURLOPT_PRIVATE=10103;

	  
	const int CURLOPT_HTTP200ALIASES=10104;

	  /* Continue to send authentication (user+password) when following locations;
	     even when hostname changed. This can potentionally send off the name
	     and password to whatever host the server decides. */
	const int CURLOPT_UNRESTRICTED_AUTH=105;

	  /* Specificly switch on or off the FTP engine's use of the EPRT command ( it
	     also disables the LPRT attempt). By default; those ones will always be
	     attempted before the good old traditional PORT command. */     
	const int CURLOPT_FTP_USE_EPRT=106;

	  /* Set this to a bitmask value to enable the particular authentications
	     methods you like. Use this in combination with CURLOPT_USERPWD.
	     Note that setting multiple bits may cause extra network round-trips. */
	const int CURLOPT_HTTPAUTH=107;

	  /* Set the ssl context callback function; currently only for OpenSSL ssl_ctx
	     in second argument. The function must be matching the
	     curl_ssl_ctx_callback proto. */
	const int CURLOPT_SSL_CTX_FUNCTION=20108;

	  /* Set the userdata for the ssl context callback function's third
	     argument */
	const int CURLOPT_SSL_CTX_DATA=10109;

	  
	const int CURLOPT_FTP_CREATE_MISSING_DIRS=110;

	  /* Set this to a bitmask value to enable the particular authentications
	     methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.
	     Note that setting multiple bits may cause extra network round-trips. */
	const int CURLOPT_PROXYAUTH=111;

	  /* FTP option that changes the timeout; in seconds; associated with 
	     getting a response.  This is different from transfer timeout time and
	     essentially places a demand on the FTP server to acknowledge commands
	     in a timely manner. */
	const int CURLOPT_FTP_RESPONSE_TIMEOUT=112;

	  /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to
	     tell libcurl to resolve names to those IP versions only. This only has
	     affect on systems with support for more than one; i.e IPv4 _and_ IPv6. */
	const int CURLOPT_IPRESOLVE=113;

	  /* Set this option to limit the size of a file that will be downloaded from
	     an HTTP or FTP server.

	     Note there is also _LARGE version which adds large file support for
	     platforms which have larger off_t sizes.  See MAXFILESIZE_LARGE below. */
	const int CURLOPT_MAXFILESIZE=114;

	  /* See the comment for INFILESIZE above; but in short; specifies
	   * the size of the file being uploaded.  -1 means unknown.
	   */
	const int CURLOPT_INFILESIZE_LARGE=115;

	  /* Sets the continuation offset.  There is also a LONG version of this;
	   * look above for RESUME_FROM.
	   */
	const int CURLOPT_RESUME_FROM_LARGE=116;

	  /* Sets the maximum size of data that will be downloaded from
	   * an HTTP or FTP server.  See MAXFILESIZE above for the LONG version.
	   */
	const int CURLOPT_MAXFILESIZE_LARGE=117;

	  /* Set this option to the file name of your .netrc file you want libcurl
	     to parse (using the CURLOPT_NETRC option). If not set; libcurl will do
	     a poor attempt to find the user's home directory and check for a .netrc
	     file in there. */
	const int CURLOPT_NETRC_FILE=10118;

	  /* Enable SSL/TLS for FTP; pick one of:
	     CURLFTPSSL_TRY     - try using SSL; proceed anyway otherwise
	     CURLFTPSSL_CONTROL - SSL for the control connection or fail
	     CURLFTPSSL_ALL     - SSL for all communication or fail
	  */
	const int CURLOPT_FTP_SSL=119;

	const int CURLOPT_LASTENTRY =120;


	alias int CURLoption;

	  /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host
	     name resolves addresses using more than one IP protocol version; this
	     option might be handy to force libcurl to use a specific IP version. */

	static const int CURL_IPRESOLVE_WHATEVER =0; /* default, resolves addresses to all IP
					     versions that your system allows */
	static const int CURL_IPRESOLVE_V4= 1;
	static const int CURL_IPRESOLVE_V6= 2;

	  
	static const int CURLOPT_WRITEDATA = CURLOPT_FILE;
	static const int CURLOPT_READDATA = CURLOPT_INFILE;
	static const int CURLOPT_HEADERDATA = CURLOPT_WRITEHEADER;


	  
	enum {
	  CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd
				     like the library to choose the best possible
				     for us! */
	  CURL_HTTP_VERSION_1_0,  
	  CURL_HTTP_VERSION_1_1,  
	  
	  CURL_HTTP_VERSION_LAST 
	};

	  
	enum  {
	  CURL_NETRC_IGNORED,     /* The .netrc will never be read.
				   * This is the default. */
	  CURL_NETRC_OPTIONAL,    /* A user:password in the URL will be preferred
				   * to one in the .netrc. */
	  CURL_NETRC_REQUIRED,    /* A user:password in the URL will be ignored.
				   * Unless one is set programmatically, the .netrc
				   * will be queried. */
	  CURL_NETRC_LAST
	};

	 alias int CURL_NETRC_OPTION;

	enum {
	  CURL_SSLVERSION_DEFAULT,
	  CURL_SSLVERSION_TLSv1,
	  CURL_SSLVERSION_SSLv2,
	  CURL_SSLVERSION_SSLv3,

	  CURL_SSLVERSION_LAST 
	};


	enum {
	  CURL_TIMECOND_NONE,

	  CURL_TIMECOND_IFMODSINCE,
	  CURL_TIMECOND_IFUNMODSINCE,
	  CURL_TIMECOND_LASTMOD,

	  CURL_TIMECOND_LAST
	} ;

	 alias int curl_TimeCond ;


	/* These functions are in libcurl, they're here for portable reasons and they
	   are used by the 'curl' client. They really should be moved to some kind of
	   "portability library" since it has nothing to do with file transfers and
	   might be usable to other programs...

	   NOTE: they return TRUE if the strings match *case insensitively*.
	 */




	enum {
	CURLFORM_NOTHING,
	  
	  
	CURLFORM_COPYNAME,
	CURLFORM_PTRNAME,
	CURLFORM_NAMELENGTH,
	CURLFORM_COPYCONTENTS,
	CURLFORM_PTRCONTENTS,
	CURLFORM_CONTENTSLENGTH,
	CURLFORM_FILECONTENT,
	CURLFORM_ARRAY,
	CURLFORM_OBSOLETE,
	CURLFORM_FILE,

	CURLFORM_BUFFER,
	CURLFORM_BUFFERPTR,
	CURLFORM_BUFFERLENGTH,

	CURLFORM_CONTENTTYPE,
	CURLFORM_CONTENTHEADER,
	CURLFORM_FILENAME,
	CURLFORM_END,
	CURLFORM_OBSOLETE2,

		CURLFORM_LASTENTRY 
	} ;

	 alias int CURLformoption;

	struct curl_forms {
		CURLformoption		option;
		char		*value;
	};


	/* Returns code for curl_formadd()
	 * 
	 * Returns:
	 * CURL_FORMADD_OK             on success
	 * CURL_FORMADD_MEMORY         if the FormInfo allocation fails
	 * CURL_FORMADD_OPTION_TWICE   if one option is given twice for one Form
	 * CURL_FORMADD_NULL           if a null pointer was given for a char
	 * CURL_FORMADD_MEMORY         if the allocation of a FormInfo struct failed
	 * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used
	 * CURL_FORMADD_INCOMPLETE     if the some FormInfo is not complete (or error)
	 * CURL_FORMADD_MEMORY         if a HttpPost struct cannot be allocated
	 * CURL_FORMADD_MEMORY         if some allocation for string copying failed.
	 * CURL_FORMADD_ILLEGAL_ARRAY  if an illegal option is used in an array
	 *
	 ***************************************************************************/
	enum   {
	  CURL_FORMADD_OK, 

	  CURL_FORMADD_MEMORY,
	  CURL_FORMADD_OPTION_TWICE,
	  CURL_FORMADD_NULL,
	  CURL_FORMADD_UNKNOWN_OPTION,
	  CURL_FORMADD_INCOMPLETE,
	  CURL_FORMADD_ILLEGAL_ARRAY,

	  CURL_FORMADD_LAST 
	} ;

	 alias int CURLFORMcode ;


}

struct curl_t ;

extern(C){
	curl_t* curl_easy_init();
	void curl_easy_cleanup(curl_t*);
	int curl_easy_setopt(curl_t*, CURLoption, ... );
	void* curl_easy_perform(curl_t*);
}


version(CurlTest){
	extern(C) void printf(char*,...);
	import 
		tango.io.Stdout ,
		tango.io.device.Array,
		tango.io.stream.Zlib,
		tango.sys.win32.CodePage,
		tango.time.Clock;
	
	extern(C) int write_cb(void* _ptr, int s, int n, Array bu){
		bu(_ptr[0 .. s*n ]);
		return n ;
	}
	void main(){
	
		auto curl	= curl_easy_init() ;
		curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
		curl_easy_setopt(curl, CURLOPT_URL , "http://www.baidu.com/\0".ptr );
		curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12\0".ptr );
		curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip\0".ptr);
		curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
		
		auto bu	= new Array(1024, 1024);
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, bu);
		auto bu2	= new Array(1024, 1024);
		curl_easy_setopt(curl, CURLOPT_HEADERDATA, bu2);
		
		curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION, &write_cb);
		

		auto now	= Clock.now;
		auto res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
		
		Stdout.formatln("{}", cast(char[]) bu2.slice);
		auto bz	= new ZlibInput(bu);
		auto b3	= new Array(1024, 1024);
		b3.copy(bz);
		char[] tmp	 ;
		tmp.length	= b3.slice.length * 2 ;
		auto _tmp	= CodePage.from(cast(char[]) b3.slice, tmp );
		Stdout.formatln("length={}", _tmp.length);
		Stdout.formatln("{}", _tmp);
		
		
		Stdout.formatln("\n{}ms", (Clock.now-now).millis);
		
	}
}